import {takeEvery, select, call, put, take} from 'redux-saga/effects'
import axios from 'axios'

// 引入自定义操作
import { DoForgetPasswd } from '../actions/forgetpasswd'

// 引入状态和常量
import { DOFORGETPASSWDSAGA } from '../constants'
import { API_URL } from '../../env'

function* doForgetPasswdSaga(action) {
    console.log("忘记密码, 用户打算修改", action.data)
    const res = yield call(axios.post, API_URL + "forgetpasswd/do", {...action.data})
    console.log("忘记密码 后端返回的结果", res.data.message)
    yield put(DoForgetPasswd(res.data.message))
}

export function* forgetPasswdSaga () {
    yield takeEvery(DOFORGETPASSWDSAGA, doForgetPasswdSaga)
}